package org.come.Jpanel;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import org.come.Frame.MsgJframe;
import org.come.bean.PathPoint;
import org.come.mouslisten.WLLMouslisten;
import org.come.until.CutButtonImage;
import org.come.until.FormsManagement;

import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;



public class FaShuKangXingJpanel extends JPanel {
    private DefaultListModel<String> dlm;
    private DefaultListModel<String> dlm1;

    public DefaultListModel<String> getDlm() {
        return dlm;
    }

    public void setDlm(DefaultListModel<String> dlm) {
        this.dlm = dlm;
    }

    public DefaultListModel<String> getDlm1() {
        return dlm1;
    }

    public void setDlm1(DefaultListModel<String> dlm1) {
        this.dlm1 = dlm1;
    }

    public JList<String> getListNo1() {
        return listNo1;
    }

    public void setListNo1(JList<String> listNo1) {
        this.listNo1 = listNo1;
    }

    public JList<String> getListNo2() {
        return listNo2;
    }

    public void setListNo2(JList<String> listNo2) {
        this.listNo2 = listNo2;
    }

    private JList<String> listNo1;
    private JList<String> listNo2;

    /**
     * 1法术抗性 2法术增强 3物理属性 4五行属性 5其他属性
     */
    private int type;

    public FaShuKangXingJpanel(int type) {
        this.type = type;
        this.setBackground(new Color(0, 0, 0, 0));
        // this.setPreferredSize(new Dimension(290, 200));
        this.setLayout(null);
        dlm = new DefaultListModel<String>();

        dlm1 = new DefaultListModel<String>();

        listNo1 = new JList<String>();
        // listNo1.setBounds(20, 26, 130, 300);
        listNo1.setForeground(Color.white);
        listNo1.setFont(UIUtils.TEXT_FONT);
        listNo1.setBackground(UIUtils.Color_BACK);
        listNo1.setModel(dlm);

        listNo1.addMouseListener(new MouseListener() {

            @Override
            public void mouseReleased(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mousePressed(MouseEvent e) {
                // TODO Auto-generated method stub
//                new WLLMouslisten(300);

                PathPoint point = GameJpanel.getGameJpanel().mousepath();
                Date date = new Date();
                DateFormat df = new SimpleDateFormat("HH:mm:ss");
                String format = df.format(date);
                MsgJframe.getJframe().getJapnel().showXFD6(format, point.getX(), point.getY()-30);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseEntered(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseClicked(MouseEvent e) {
                // 打开了窗体
                if (e.isMetaDown()) {// 检测鼠标右键单击
                    FormsManagement.HideForm(8);
                }

            }
        });
        this.add(listNo1);
        listNo2 = new JList<String>();
        // listNo2.setBounds(150, 26, 130, 100);
        listNo2.setOpaque(false);
        listNo2.setForeground(Color.white);
        listNo2.setFont(UIUtils.TEXT_FONT);
        listNo2.setBackground(UIUtils.Color_BACK);
        listNo2.setModel(dlm1);
        listNo2.addMouseListener(new MouseListener() {

            @Override
            public void mouseReleased(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mousePressed(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseExited(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseEntered(MouseEvent e) {
                // TODO Auto-generated method stub

            }

            @Override
            public void mouseClicked(MouseEvent e) {
                // 打开了窗体
                if (e.isMetaDown()) {// 检测鼠标右键单击
                    FormsManagement.HideForm(8);
                }

            }
        });
        this.add(listNo2);

        // this.pack();
    }

    private ImageIcon icon;
    private ImageIcon iconBack;
    private ImageIcon iconBottom;

    @Override
    protected void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        super.paintComponent(g);
        if (MyIsif.getStyle().equals("水墨UI")) {
            iconBack = new ImageIcon("inkImg/newbackground/S200.png");
            iconBottom = CutButtonImage.getImage("inkImg/newbackground/S206.png", -1, -1);
            if (icon == null) {
                switch (type) {
                    case 1:
                        icon = CutButtonImage.getImage("inkImg/newbackground/S201.png", -1, -1);
                        break;
                    case 2:
                        icon = CutButtonImage.getImage("inkImg/newbackground/S202.png", -1, -1);
                        break;
                    case 3:
                        icon = CutButtonImage.getImage("inkImg/newbackground/S203.png", -1, -1);
                        break;
                    case 4:
                        icon = CutButtonImage.getImage("inkImg/newbackground/S204.png", -1, -1);
                        break;
                    case 5:
                        icon = CutButtonImage.getImage("inkImg/newbackground/S205.png", -1, -1);
                        break;
                    default:
                        break;
                }
            }
            // 设置背景
            if (this.getHeight() > 34)
                g.drawImage(iconBack.getImage(), 0, 0, 300, this.getHeight() - 8, this);
//        g.drawImage(iconBack.getImage(), 0, 4, 290, this.getHeight() - 8, this);
            // 设置底框
            if (this.getHeight() > 34)
                g.drawImage(iconBottom.getImage(), 0, this.getHeight() - 8, 300, 8, this);
//        g.drawImage(iconBottom.getImage(), 0, this.getHeight() - 4, 290, 4, this);

            g.drawImage(icon.getImage(), 0, 0, 300, 20, this);
        } else {
//        	iconBack = new ImageIcon("inkImg/hongmu/2/kx_zj.png");
            iconBack = new ImageIcon("inkImg/hongmu/2/resistance-content-bg.png");
//            iconBottom = CutButtonImage.getImage("inkImg/hongmu/2/personalLast.png", -1, -1);
            iconBottom = CutButtonImage.getImage("inkImg/hongmu/2/resistance-footer-bg.png", -1, -1);
            if (icon == null) {
                switch (type) {
                    case 1:
//        			icon = CutButtonImage.getImage("inkImg/hongmu/2/kx_kx.png", -1, -1);
                        icon = CutButtonImage.getImage("inkImg/hongmu/2/resistance-header-kx.png", -1, -1);
                        break;
                    case 2:
//        			icon = CutButtonImage.getImage("inkImg/hongmu/2/kx_zq.png", -1, -1);
                        icon = CutButtonImage.getImage("inkImg/hongmu/2/resistance-header-zq.png", -1, -1);
                        break;
                    case 3:
//        			icon = CutButtonImage.getImage("inkImg/hongmu/2/kx_wl.png", -1, -1);
                        icon = CutButtonImage.getImage("inkImg/hongmu/2/resistance-header-wl.png", -1, -1);
                        break;
                    case 4:
//        			icon = CutButtonImage.getImage("inkImg/hongmu/2/kx_wx.png", -1, -1);
                        icon = CutButtonImage.getImage("inkImg/hongmu/2/resistance-header-wx.png", -1, -1);
                        break;
                    case 5:
//        			icon = CutButtonImage.getImage("inkImg/hongmu/2/kx_qt.png", -1, -1);
                        icon = CutButtonImage.getImage("inkImg/hongmu/2/resistance-header-qt.png", -1, -1);
                        break;
                    default:
                        break;
                }
            }

            // 设置背景
            if (this.getHeight() > 34)
                g.drawImage(iconBack.getImage(), 0, 4, 290, this.getHeight() - 8, this);
            // 设置底框
            if (this.getHeight() > 34)
                g.drawImage(iconBottom.getImage(), 0, this.getHeight() - 4, 290, 4, this);

            g.drawImage(icon.getImage(), 0, 0, 290, 24, this);

        }
    }

}
